//
//  MSAttendanceCardCell.m
//  美娱
//
//  Created by No.8 on 2019/4/10.
//  Copyright © 2019 No.8. All rights reserved.
//

#import "MSAttendanceCardCell.h"

@implementation MSAttendanceCardCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    
    MSAttendanceCardCell * cell = [tableView dequeueReusableCellWithIdentifier:[MSAttendanceCardCell ID]];
    cell = [[MSAttendanceCardCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[MSAttendanceCardCell ID]];
    cell.backgroundColor = backgroundcolor;
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setMember];
        
    }
    return self;
}

- (void)setMember{
    
    /** 年*/
    self.yearLabel = [[UILabel alloc] initWithFrame:CGRectMake(60 * px, 20 * px, 200 * px, 60 * px)];
    self.yearLabel.textColor = [UIColor grayColor];
    self.yearLabel.text = @"2018";
    self.yearLabel.textAlignment = NSTextAlignmentRight;
    self.yearLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self addSubview:self.yearLabel];
    
    
    /** 月*/
    self.monthLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.yearLabel.x, CGRectGetMaxY(self.yearLabel.frame), self.yearLabel.width, self.yearLabel.height)];
    self.monthLabel.textColor = [UIColor whiteColor];
    self.monthLabel.text = @"08-30";
    self.monthLabel.textAlignment = self.yearLabel.textAlignment;
    self.monthLabel.font = [UIFont systemFontOfSize:SYRealValue(32 / 2)];
    [self addSubview:self.monthLabel];
    
    
    
    /** 上线*/
    self.topLineView = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.yearLabel.frame) + 50 * px, 0, 1, self.yearLabel.height)];
    self.topLineView.backgroundColor = BackViewColor;
    [self addSubview:self.topLineView];
    
    
    /** 中间点*/
    self.redView = [[UIView alloc] initWithFrame:CGRectMake(self.topLineView.x - 10 * px, CGRectGetMaxY(self.topLineView.frame), 30 * px, 30 * px)];
    self.redView.backgroundColor = FontColor;
    self.redView.layer.cornerRadius = 15 * px;
    [self addSubview:self.redView];
    
    /** 上线*/
    self.lowerLineView = [[UIView alloc] initWithFrame:CGRectMake(self.topLineView.x, CGRectGetMaxY(self.redView.frame), self.topLineView.width, 200 * px - self.topLineView.height - self.redView.height)];
    self.lowerLineView.backgroundColor = self.topLineView.backgroundColor;
    [self addSubview:self.lowerLineView];
    
    
    /** 签到时间*/
    self.SignintimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.topLineView.frame) + 40 * px, self.topLineView.y, 200 * px, self.yearLabel.height)];
    self.SignintimeLabel.textColor = [UIColor whiteColor];
    self.SignintimeLabel.text = @"18:28:03";
    self.SignintimeLabel.textAlignment = NSTextAlignmentLeft;
    self.SignintimeLabel.font = [UIFont systemFontOfSize:SYRealValue(32 / 2)];
    [self addSubview:self.SignintimeLabel];
    
    
    /** 签到*/
    self.SigninLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.SignintimeLabel.frame) + 20 * px, self.SignintimeLabel.y + 5 * px, 120 * px, self.yearLabel.height - 10 * px)];
    self.SigninLabel.textColor = [UIColor whiteColor];
    self.SigninLabel.backgroundColor = WYCRGBColor(114, 134, 158);
    self.SigninLabel.layer.cornerRadius = (self.yearLabel.height - 10 * px) / 2;
    self.SigninLabel.layer.masksToBounds = YES;
    self.SigninLabel.text = @"签到";
    self.SigninLabel.textAlignment = NSTextAlignmentCenter;
    self.SigninLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self addSubview:self.SigninLabel];
    
    
    /** 签退时间*/
    self.SignbacktimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.SignintimeLabel.x, CGRectGetMaxY(self.SignintimeLabel.frame) + 20 * px, self.SignintimeLabel.width, self.yearLabel.height)];
    self.SignbacktimeLabel.textColor = [UIColor whiteColor];
    self.SignbacktimeLabel.text = @"18:28:03";
    self.SignbacktimeLabel.textAlignment = self.SignintimeLabel.textAlignment;
    self.SignbacktimeLabel.font = [UIFont systemFontOfSize:SYRealValue(32 / 2)];
    [self addSubview:self.SignbacktimeLabel];
    
    
    /** 签到*/
    self.SignbackLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.SigninLabel.x, self.SignbacktimeLabel.y + 5 * px, self.SigninLabel.width, self.SigninLabel.height)];
    self.SignbackLabel.textColor = [UIColor whiteColor];
    self.SignbackLabel.backgroundColor = WYCRGBColor(114, 134, 158);
    self.SignbackLabel.layer.cornerRadius = self.SigninLabel.layer.cornerRadius;
    self.SignbackLabel.layer.masksToBounds = YES;
    self.SignbackLabel.text = @"签退";
    self.SignbackLabel.textAlignment = NSTextAlignmentCenter;
    self.SignbackLabel.font = self.SigninLabel.font;
    [self addSubview:self.SignbackLabel];
    
    
    /** 商家*/
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.SignbackLabel.frame) + 40 * px, CGRectGetMaxY(self.SigninLabel.frame), 200 * px, 50 * px)];
    self.titleLabel.textColor = WYCRGBColor(92, 202, 180);
    self.titleLabel.text = @"天天ktv";
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.layer.cornerRadius = 25 * px;
    self.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(26 / 2)];
    self.titleLabel.layer.borderColor = WYCRGBColor(92, 202, 180).CGColor;//颜色
    self.titleLabel.layer.borderWidth = 1.0f;//设置边框粗细
    self.titleLabel.layer.masksToBounds = YES;
    [self addSubview:self.titleLabel];
    
}
- (void)setAttendDanceCardModel:(MSAttendDanceCardModel *)AttendDanceCardModel{
    _AttendDanceCardModel = AttendDanceCardModel;
    
    NSString *string = [NSString stringWithFormat:@"%@",AttendDanceCardModel.formatTime];
    
    NSArray *array = [string componentsSeparatedByString:@"-"]; //从字符A中分隔成2个元素的数组
    
    self.yearLabel.text = [NSString stringWithFormat:@"%@",array[0]];
    
    self.monthLabel.text =[NSString stringWithFormat:@"%@-%@",array[1],array[2]];
    
    self.SignintimeLabel.text = [NSString stringWithFormat:@"%@",AttendDanceCardModel.goWorkTime];
   if ([AttendDanceCardModel.upWorkStruts isEqualToString:@"2"]) {
        self.SigninLabel.backgroundColor = WYCRGBColor(95, 207, 185);
       self.SigninLabel.text = @"签到";
       self.SigninLabel.textColor = [UIColor whiteColor];
        
   }else  if ([AttendDanceCardModel.upWorkStruts isEqualToString:@"7"]) {
       self.SigninLabel.backgroundColor = WYCRGBColor(78, 95, 117);
       self.SigninLabel.text = @"缺卡";
       self.SigninLabel.textColor = [UIColor whiteColor];
       
   }else{
        self.SigninLabel.backgroundColor = FontColor;
        self.SigninLabel.text = @"迟到";
        self.SigninLabel.textColor = [UIColor whiteColor];
    }
    
    self.SignbacktimeLabel.text = [NSString stringWithFormat:@"%@",AttendDanceCardModel.offTime];
    if ([AttendDanceCardModel.endWorkStruts isEqualToString:@"4"]) {
        self.SignbackLabel.backgroundColor = FontColor;
        self.SignbackLabel.text = @"早退";
        self.SignbackLabel.textColor = [UIColor whiteColor];
    }else  if ([AttendDanceCardModel.endWorkStruts isEqualToString:@"7"]) {
        self.SignbackLabel.backgroundColor = WYCRGBColor(78, 95, 117);
        self.SignbackLabel.text = @"缺卡";
        self.SignbackLabel.textColor = [UIColor whiteColor];
        
    }else{
        
        self.SignbackLabel.backgroundColor = WYCRGBColor(95, 207, 185);
        self.SignbackLabel.text = @"签退";
        self.SignbackLabel.textColor = [UIColor whiteColor];
    }
    
    self.titleLabel.text = [NSString stringWithFormat:@"%@",AttendDanceCardModel.businessName];
}

+(NSString *)ID{
    return @"cell";
}

@end
